import { IdentityCodeValid } from './util'
/**
 * 验证新增乘客与修改乘客的信息
 */

export const passengerMessVerificate = data => {
	//乘机人姓名
	if(data.firstNameCn==""||data.firstNameCn=="/") return {status:0,msg:"乘客姓名不能为空"};
	//证件号
	if(data.docId=="") return {status:0,msg:"证件号不能为空"};
	//身份证校验
	if(data.docType=="1"&&!(IdentityCodeValid(data.docId))) return {status:0,msg:"身份证格式有误"};
	//证件有效期
	if(data.docExpireDate!=undefined&&data.docExpireDate=="") return {status:0,msg:"证件有效期不能为空"};
	//手机号
	if(data.mobile=="") return {status:0,msg:"手机号码不能为空"};
	else if(!(/^1[34578]\d{9}$/.test(data.mobile))) return {status:0,msg:"手机号码格式有误"};
	//国籍
	if(data.nationality!=undefined){
		if(data.nationality=="") return {status:0,msg:"国籍不能为空"};
		if(!(/^[A-Z]{2}$/.test(data.nationality))) return {status:0,msg:"国籍为二字码格式"};
	}	
	return {status:1,msg:"success"};
}